import "package:ct_pa_majordomo/widgets/normal_scaffold/index.dart";
import 'package:flutter/material.dart';
import 'package:ct_pa_majordomo/config/theme_vars.dart';
import 'package:ct_pa_majordomo/router/keys.dart';
import 'package:ct_pa_majordomo/utils/stacker.dart';

class UtilitiesRechargePage extends StatelessWidget {
  final Map arguments;

  const UtilitiesRechargePage({Key? key, required this.arguments}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return NormalScaffold(
      title: "水电充值",
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            padding: const EdgeInsets.all(ThemeVars.paddingPage),
            alignment: Alignment.centerLeft,
            child: Text(
              "${arguments['buildingName']} ${arguments['roomName']}",
              style: const TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500
              ),
            ),
          ),
          _buildRechargeItem(
            title: "电费充值",
            icon: Icons.electric_bolt,
            onTap: () {
              Stacker.pushNamed(
                Keys.APARTMENT_RECHARGE,
                arguments: {
                  ...arguments,
                  "type": "electricity"
                }
              );
            }
          ),
          // _buildRechargeItem(
          //   title: "水费充值",
          //   icon: Icons.water_drop,
          //   onTap: () {
          //     Stacker.pushNamed(
          //       Keys.APARTMENT_RECHARGE,
          //       arguments: {
          //         ...arguments,
          //         "type": "water"
          //       }
          //     );
          //   }
          // ),
        ],
      ),
    );
  }

  Widget _buildRechargeItem({
    required String title,
    required IconData icon,
    required VoidCallback onTap
  }) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.all(ThemeVars.paddingPage),
        margin: const EdgeInsets.symmetric(
          horizontal: ThemeVars.paddingPage,
          vertical: 8
        ),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(8),
        ),
        child: Row(
          children: [
            Container(
              width: 40,
              height: 40,
              decoration: BoxDecoration(
                color: ThemeVars.colorPrimaryLight,
                borderRadius: BorderRadius.circular(20),
              ),
              child: Icon(icon, color: ThemeVars.colorPrimary),
            ),
            const SizedBox(width: 12),
            Expanded(
              child: Text(
                title,
                style: const TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500
                ),
              ),
            ),
            const Icon(
              Icons.arrow_forward_ios,
              size: 16,
              color: ThemeVars.colorTextTer,
            ),
          ],
        ),
      ),
    );
  }
} 